class Dog {
    public String name;
    public String color;
    public int age;

    public Dog() {
        this("cc", 18);//只能在当前构造方法内部使用，并且只能在第一行
        System.out.println("不带参数的构造方法!");
    }

    public Dog(String name, int age) {
        this.name = name;
        this.age = age;
        System.out.println("带有两个参数的构造方法!");
    }

    //狗的行为
    public void barks() {
        System.out.println("汪汪汪~~~");
    }

    public void wag() {
        System.out.println("摇尾巴~~~");
        this.show();
    }

    public void show() {
        System.out.println("姓名:" + this.name + "  年龄:" + this.age);
    }
}

public class Test {
    public static void main(String[] args) {
        Dog dog1 = new Dog();
        Dog dog2 = new Dog("小白", 3);
        dog2.wag();
    }

    public static void main1(String[] args) {
        //通过new来实例化对象
        Dog dog1 = new Dog();
        dog1.name = "大黄";
        dog1.color = "黄色";
        dog1.age = 3;
        dog1.barks();
        dog1.wag();

        Dog dog2 = new Dog();
        dog2.name = "大黑";
        dog2.color = "黑色";
        dog2.age = 4;
        dog2.barks();
        dog2.wag();
    }
}
